package cn.imvc.app.models;

import java.util.List;
import java.util.Map;

import cn.imvc.app.entities.Cart;
import cn.imvc.app.entities.Member;

public interface CartModel {
	/**
	 * 加入购物车
	 * 
	 * @param goodsId
	 * @param skuId
	 * @param member
	 * @return
	 */
	public Cart saveInCart(Integer goodsId, Integer skuId, Member member);

	/**
	 * 展示购物车
	 * 
	 * @param member
	 * @param cookieCartItemsStr
	 *            cookie购物项
	 * @return
	 */
	public List<Cart> listCartItems(Member member, String cookieCartItemsStr);

	/**
	 * 本地保存购物车item信息
	 * 
	 * @param goodsId
	 * @param skuId
	 * @param num
	 */
	public String saveInCookieCart(Integer goodsId, Integer skuId, Integer num);

	/**
	 * 购物项保存数据库
	 * 
	 * @param goodsId
	 * @param skuId
	 * @param num
	 * @param member
	 * @param cartItemsString
	 */
	public List<Cart> saveInDBCart(Integer goodsId, Integer skuId, Integer num, Member member, String cartItemsString);

	/**
	 * 根据本次添加的商品信息和cookie中的购物车信息获取购物车信息串
	 * 
	 * @param cartItemsStr
	 *            cookie中存放的购物车信息
	 * @param goodsId
	 * @param skuId
	 * @param num
	 * @return
	 */
	public String getCartItemsStr(String cartItemsStr, Integer goodsId, Integer skuId, Integer num);

	/**
	 * 修改购物项数量或者删除购物项(针对cookie)
	 * 
	 * @param cartItemsStr
	 * @param goodsId
	 * @param skuId
	 * @param num
	 * @param optionType
	 *            1:修改 2：删除
	 * @return
	 */
	public String changeCountOrDelCarItems(String cartItemsStr, Integer goodsId, Integer skuId, Integer num, byte optionType);

	/**
	 * 根据cookie字符串构建cart集合
	 * 
	 * @param cookieCartItemsStr
	 * @return
	 */
	public List<Cart> getCookieCartItems(String cookieCartItemsStr);

	/**
	 * 删除购物项
	 * 
	 * @param goodsId
	 * @param skuId
	 * @param member
	 */
	public void removeFromCart(Integer goodsId, Integer skuId, Member member);

	/**
	 * 修改购物项
	 * 
	 * @param goodsId
	 * @param skuId
	 * @param num
	 * @param member
	 */
	public void changeCartItemCount(Integer goodsId, Integer skuId, Integer num, Member member);
	/**
	 * 同步并展示购物车
	 * 
	 * @param member
	 * @param cookieCartItemsStr
	 *            cookie购物项
	 * @param member
	 * @param cookieCartItemsStr
	 * @return
	 */
	Map<String, Object> updateAndListCartItems(Member member, String cookieCartItemsStr);
	/**
	 * 根据 集合 生成cookie信息串
	 * @param carts
	 * @return
	 */
	String generateCookieStrByCarts(List<Cart> carts);
	/**
	 * 构建购物项
	 * @param goodsId
	 * @param skuId
	 * @param num
	 * @param member
	 * @param checkGift 是否检验是赠品
	 * @return
	 */
	Cart bulidCartItem(Integer goodsId, Integer skuId, Integer num, Member member,boolean checkGift);

}
